Page({

  /**
   * 页面的初始数据
   */
  data: {
    option:'',
    sourceId:'',
    coverMain:'',
    count:'',
    pkgId:'',
    name:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    var option = JSON.parse(options.presentPackage);
    console.log(option)
    var sourceId = option.courseId; //专辑id
    var coverMain = option.courseLogo; // 封面
    var count = option.remainQty; //可赠送的份数
    var pkgId = option.id; //子包id
    var name = option.courseName; //专辑名字
    var price = option.price;
    var prices = price/100;
    option.prices = prices;
    this.setData({  
      option:option,
      sourceId: sourceId,
      coverMain: coverMain,
      count: count,
      pkgId: pkgId,
      name:name
    })
  },

  //跳转去观看
  towatch: function (event) {
    var id = event.currentTarget.dataset.id;
    var mediaType = event.currentTarget.dataset.mediaType;
    console.log(id)
    console.log(mediaType)
    if (mediaType == 'AUDIO') {
      wx.navigateTo({
        url: '../audioAlbumDetail/audioAlbumDetail?id=' + id
      })
    } else {
      wx.navigateTo({
        url: '../videoAlbumDetail/videoAlbumDetail?id=' + id
      })
    }
  },

  //点击包装并赠送
  togiveGift:function(){
    var sourceId = this.data.sourceId;  //专辑id
    var coverMain = this.data.coverMain;  //封面
    var count = this.data.count;  //可赠送的份数
    var pkgId = this.data.pkgId; //子包id
    var name = this.data.name; //子包name
    wx.navigateTo({
      url: '../markGiftCard/markGiftCard?sourceId=' + sourceId + '&coverMain=' + coverMain + '&count=' + count + '&pkgId=' +pkgId + '&name='+ name,
    })
  },
})